<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h2>{{count}}</h2>
        <button @click="add">+</button>
        <button @click="sub">-</button>

        <!-- 阻止冒泡 -->
        <div @click="divClick" style="width: 100px;background-color:red;">
            
            <button @click.stop="btnClick">点击</button>
        </div>
        <!-- 阻止默认 -->
        <a href="https://www.baidu.com" @click.prevent="aClick">点击</a>
        <!-- 执行一次 @click.once -->

    </div>
    <script src="vue/vue.js"></script>
    <script>
        const vm=new Vue({
            el:'#app',
            data:{
                count:0
            },
            methods:{
                add(){
                this.count++
                },
                sub(){
                this.count--
                },
                divClick(){
                    console.log('div被点击')
                },
                btnClick(){
                    console.log('btn被点击')
                },
                aClick(){
                    console.log('a元素被点击')
                }
            },
            computed:{}
        });
    </script>
</body>
</html>